package com.smart.test.proxy.advice;

import org.springframework.aop.ThrowsAdvice;

import java.lang.reflect.Method;

/**
 * @auther a123
 * @create 2018-08-14 20:27
 * @desc 实现后置增强
 */
public class GreetingThrowAdvice implements ThrowsAdvice {

    /**
     * 注意此处方法名称不能写错， 否则aop截获不到
     * @param method
     * @param args
     * @param target
     * @param ex
     * @throws Throwable
     */
    public void afterThrowing(Method method, Object[] args, Object target, Exception ex) throws Throwable{
        System.out.println("---------");
        System.out.println("method:" + method.getName());
        System.out.println("throw exception : " + ex.getMessage());
    }
}
